package pres.lzx.music;

public class AudioUtil {
    public enum TimeUnit {
        SECONDS(1L),
        MILLISECOND(1000L),
        MICROSECOND(1000000L);

        TimeUnit(long unit) {
            this.unit = unit;
        }

        private final long unit;

        public long getUnit() {
            return unit;
        }
    }

    public static String getDurationFormatString(long duration, TimeUnit timeUnit) {
        // 将时间转化秒
        duration = duration / timeUnit.getUnit();
        long minute = duration / 60;

        long seconds = duration % 60;
        return minute + ":" + seconds;
    }
}
